<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/saferequest.asp"-->
<%
Function chkcntrno(xh)
	Dim fi_ki
	Dim fi_numsum
	Dim fi_nummod
	Dim fai_num(11)
	If IsNull(xh) Or xh="" Then
		chkcntrno="<span style='color:red;'>请输入箱号！</span>"
		Exit Function
	End If
	If Len(xh)=11 Then
		For fi_ki=1 To 11
			fai_num(fi_ki)=0
		Next
		For fi_ki=1 To 4
			fch_char=Mid(xh,fi_ki,1)
				If fch_char="A" Then
					fai_num(fi_ki)=10
				ElseIf fch_char>="V" And fch_char<="Z" Then
					fai_num(fi_ki)=Asc(fch_char)-52
				ElseIf fch_char>="L" And fch_char<="U" Then
					fai_num(fi_ki)=Asc(fch_char)-53
				Else
					fai_num(fi_ki)=Asc(fch_char)-54
				End If
		Next
		For fi_ki=5 To 11
			fch_char=Mid(xh,fi_ki,1)
			fai_num(fi_ki)=CInt(fch_char)
		Next
		fi_numsum=0
		For fi_ki=1 To 10
			fi_sqr=1
			For i=1 To fi_ki-1
				fi_sqr=fi_sqr*2
			Next
			fi_numsum=fi_numsum+fai_num(fi_ki)*fi_sqr
		Next
		If Left(xh,4)="HLCU" Then fi_numsum=fi_numsum-2
		fi_nummod=fi_numsum Mod 11
		If fi_nummod=10 Then fi_nummod=0
		If fi_nummod=fai_num(11) Then
			chkcntrno="<span style='color:green;'>箱号正确！</span>"
		Else
			chkcntrno="<span style='color:red;'>箱号校验错误，请检查！</span>"
		End If
	Else
		chkcntrno="<span style='color:red;'>箱号不是11位，请检查！</span>"
	End If
End Function
If Request.QueryString("xh")<>"" Then xh=Trim(saferequest("xh",0))
Response.Write(chkcntrno(xh))
%>
